import qrcode
import base64
from io import BytesIO

def createCode(params):
    content = params.get('content')
    img = qrcode.make(content)
    # 写入文件
    with open('test' + '.png', 'wb') as f:
        img.save(f)

    buffered = BytesIO()
    img.save(buffered, format="PNG")
    image_base64 = str(base64.b64encode(buffered.getvalue()), encoding='utf-8')

    # print('image_base64', image_base64)
    return image_base64